package com.example.codegenerator;

import com.example.codegenerator.Constant.PathConstant;
import freemarker.template.Configuration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.io.File;
import java.io.IOException;

@SpringBootApplication
public class CodegeneratorApplication {

    public static void main(String[] args) {
        SpringApplication.run(CodegeneratorApplication.class, args);
    }

    @Bean
    public Configuration configuration(){
        Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);

        try {
            cfg.setDirectoryForTemplateLoading(new File(PathConstant.templatePath));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        cfg.setDefaultEncoding("UTF-8");
        return cfg;
    }
}
